<?php
App::import('Sanitize');
class PitchesController extends AppController {

	var $name = 'Pitches';

	function index($filter = 'all') {
		$pitches = $this->Pitch->get_pitches($filter);
		$pitches = Sanitize::clean($pitches, array('escape' => false, 'carriage' => true, 'encode' => false));
		$this->set(compact('pitches'));
	}
	
	function get_random() {
		$pitches = $this->Pitch->get_random();
		$pitches = Sanitize::clean($pitches, array('escape' => false, 'carriage' => true, 'encode' => false));
		if (isset($this->params['requested']))
			return $pitches;
		else
			$this->set(compact('pitches'));
	}

	function view($id = null) {
		if (!$id) {
			//$this->Session->setFlash(__('Invalid pitch', true));
			$this->redirect(array('action' => 'index'));
		}
		if ($pitch = $this->Pitch->get_pitch($id)) {
			$pitch = Sanitize::clean($pitch, array('escape' => false, 'carriage' => true, 'encode' => false));
			$this->set('pitch', $pitch);
		} else {
			$this->redirect($this->referer());
		}
	}
}
?>
